#!/usr/bin/env bash
set -euo pipefail

# 安装 npm 依赖
echo 'Installing npm dependencies...'
pnpm install

# 生成 Tailwind CSS safelist
echo 'Generating Tailwind CSS safelist...'
pnpm run gen:safelist

# 构建 CSS 文件
echo 'Building CSS...'
pnpm run build:css

# 确保输出目录存在
mkdir -p ./target/assets

# 复制 CSS 文件到目标目录
cp -r ./assets/css ./target/assets/

# 运行 Rust 代码格式化和检查
echo 'Running cargo fmt...'
cargo fmt --all

echo 'Running cargo clippy...'
cargo clippy --all-targets --all-features -- -D warnings

# 构建 Rust 库
echo 'Building Rust library...'
cargo build --release

echo 'Release build completed successfully!'
